package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 岗位服务类型对照表
 */
@Entity
@Table(name = "tnb_position_servicetype")
@JsonApiResource(type = "positionservicetype")
public class PositionServiceType extends BaseEntity {

	private Dicttype position;// 岗位
	
	private Dicttype serviceType;// 服务类型
	
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "position_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPosition() {
		return position;
	}

	public void setPosition(Dicttype position) {
		this.position = position;
	}
	
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "servicetype_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getServiceType() {
		return serviceType;
	}

	public void setServiceType(Dicttype serviceType) {
		this.serviceType = serviceType;
	}

}